<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="data" />
        <cc:attribute name="income" />
        <cc:attribute name="expenss" />
        <cc:attribute name="credit" />
        <cc:attribute name="debit" />
        <cc:attribute name="cancel" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:dataTable id="#{cc.id}" value="#{cc.attrs.data.bills}" var="b"   sortBy="#{b.billType}" rendered="#{cc.attrs.data.bills.size()>0}" >
            <f:facet name="header">  
                <h:outputLabel value="Channel Income Bills " rendered="#{cc.attrs.income}"/>
                <h:outputLabel value="Channel Expencess Bills " rendered="#{cc.attrs.expenss}"/>
                <h:outputLabel value="Channel Credit Note Bills " rendered="#{cc.attrs.credit}"/>
                <h:outputLabel value="Channel Debit Note Bills " rendered="#{cc.attrs.debit}"/>
                <h:outputLabel value="Cancell" rendered="#{cc.attrs.cancel}"/>
                
            </f:facet> 
            <p:column headerText="Time" rendered="#{commonReport.fromDate ne commonReport.toDate}"  >
                <f:facet name="header">  
                    <h:outputLabel value="Time"/>
                </f:facet>
                <h:outputLabel value="#{b.createdAt}"  >
                    <f:convertDateTime pattern="hh:mm:ss a"/>
                </h:outputLabel>
            </p:column>                        
            <p:column headerText="Id" >
                <f:facet name="header">  
                    <h:outputLabel value="ID"/>
                </f:facet>
                <h:outputLabel value="#{b.insId}"/>
            </p:column>
            <p:column headerText="Ref. Bill" rendered="#{cc.attrs.cancel}" >
                <f:facet name="header">  
                    <h:outputLabel value="Ref. Bill"/>
                </f:facet>
                <h:outputLabel value="#{b.billedBill.insId}"/>
            </p:column>
            <p:column headerText="Discription"  >
                <f:facet name="header">  
                    <h:outputLabel value="Discription"/>
                </f:facet>
                <h:outputLabel value="#{b.comments}"/>
            </p:column>
            <p:column headerText="Cash" style=" text-align: right"  >
                <f:facet name="header">  
                    <h:outputLabel value="Cash"/>
                </f:facet> 
                <h:outputLabel rendered="#{b.paymentMethod=='Cash'}" value="#{b.vat+b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Cash'}" value="0.00" />
            </p:column>
            <p:column headerText="Credit" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="Credit"/>
                </f:facet> 
                <h:outputLabel rendered="#{b.paymentMethod=='Credit' or b.paymentMethod=='Agent'}" value="#{b.vat+b.netTotal}"  >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Credit' and b.paymentMethod!='Agent'}" value="0.00"/>

            </p:column>
            <p:column headerText="C Card" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="C Card"/>
                </f:facet> 
                <h:outputLabel rendered="#{b.paymentMethod=='Card'}" value="#{b.vat+b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Card'}" value="0.00"/>
            </p:column>

            <p:column headerText="Checque" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="Checque"/>
                </f:facet> 
                <h:outputLabel rendered="#{b.paymentMethod=='Cheque'}" value="#{b.vat+b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Cheque'}" value="0.00"/>
            </p:column>

            <p:column headerText="Slip" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="Slip"/>
                </f:facet> 
                <h:outputLabel rendered="#{b.paymentMethod=='Slip'}" value="#{b.vat+b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Slip'}" value="0.00"/>
            </p:column>

            <p:column exportable="false">
                <p:selectBooleanCheckbox style="border: black 2px solid;"/>
            </p:column>
            <p:columnGroup type="footer"> 
                <p:row>                                 
                    <p:column colspan="3"/>
                    <p:column rendered="#{cc.attrs.cancel}" />
                    <p:column footerText="#{cc.attrs.data.cash}" style=" text-align: right">
                        <f:facet name="footer">
                            <h:outputLabel value="#{cc.attrs.data.cash}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                    <p:column footerText="#{cc.attrs.data.credit}" style=" text-align: right">
                        <f:facet name="footer">
                            <h:outputLabel value="#{cc.attrs.data.credit}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                    <p:column footerText="#{cc.attrs.data.card}" style=" text-align: right">  
                        <f:facet name="footer">
                            <h:outputLabel value="#{cc.attrs.data.card}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                    <p:column footerText="#{cc.attrs.data.cheque}" style=" text-align: right"> 
                        <f:facet name="footer">
                            <h:outputLabel value="#{cc.attrs.data.cheque}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                    <p:column footerText="#{cc.attrs.data.slip}" style=" text-align: right">
                        <f:facet name="footer">
                            <h:outputLabel value="#{cc.attrs.data.slip}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                </p:row>  

            </p:columnGroup>  
        </p:dataTable>
    </cc:implementation>
</html>